package com.payment.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.payment.common.annotation.Log;
import com.payment.common.enums.BusinessType;
import com.payment.system.domain.IssBank;
import com.payment.system.service.IIssBankService;
import com.payment.framework.web.base.BaseController;
import com.payment.common.page.TableDataInfo;
import com.payment.common.base.AjaxResult;
import com.payment.common.utils.ExcelUtil;

/**
 * 银行开户行 信息操作处理
 * 
 * @author payment
 * @date 2018-12-26
 */
@Controller
@RequestMapping("/system/issBank")
public class IssBankController extends BaseController
{
    private String prefix = "system/issBank";
	
	@Autowired
	private IIssBankService issBankService;
	
	@RequiresPermissions("system:issBank:view")
	@GetMapping()
	public String issBank()
	{
	    return prefix + "/issBank";
	}
	
	/**
	 * 查询银行开户行列表
	 */
	@RequiresPermissions("system:issBank:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(IssBank issBank)
	{
		startPage();
        List<IssBank> list = issBankService.selectIssBankList(issBank);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出银行开户行列表
	 */
	@RequiresPermissions("system:issBank:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(IssBank issBank)
    {
    	List<IssBank> list = issBankService.selectIssBankList(issBank);
        ExcelUtil<IssBank> util = new ExcelUtil<IssBank>(IssBank.class);
        return util.exportExcel(list, "issBank");
    }
	
	/**
	 * 新增银行开户行
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存银行开户行
	 */
	@RequiresPermissions("system:issBank:add")
	@Log(title = "银行开户行", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(IssBank issBank)
	{		
		return toAjax(issBankService.insertIssBank(issBank));
	}

	/**
	 * 修改银行开户行
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") String id, ModelMap mmap)
	{
		IssBank issBank = issBankService.selectIssBankById(id);
		mmap.put("issBank", issBank);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存银行开户行
	 */
	@RequiresPermissions("system:issBank:edit")
	@Log(title = "银行开户行", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(IssBank issBank)
	{		
		return toAjax(issBankService.updateIssBank(issBank));
	}
	
	/**
	 * 删除银行开户行
	 */
	@RequiresPermissions("system:issBank:remove")
	@Log(title = "银行开户行", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(issBankService.deleteIssBankByIds(ids));
	}
	
}
